<<<<<<< HEAD
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Conset extends MY_Controller {
		
	function __construct(){
		parent::__construct();
		/** 登陆验证 */
		if(!isset($_SESSION)){
		    session_start();
		}
		$admin = $this->session->userdata('admin_user');
		if(!$admin || !isset($admin['user_id'])){
			header('Location: /sys_admin/login');
			exit;
		}
		
		$this->tab = 'borrowtender';
	}
	
	
	/*
	 * 借款用途设置
	 */
	function zhs_borrowuse(){
		
		//接收参数
		$per_page 			= $this->input->get('per_page')?$this->input->get('per_page'):0;
		$title 				= $this->input->get('title');
		
		$data = array();
		if($title != ''){
			$data['where']['title'] = $title;
		}
		
		$data['page_size']  = sys_admin_LIST_PAGE_SIZE;
		$data['page_start'] = (int)$per_page;
		$data['select'] 	= 1;
		$this->load->model('Conset_model');
		$vdata = $this->Conset_model->get_conset_use_list($data);
		
		//分页
		$this->load->library('pagination');
		$config['base_url'] = '/sys_admin/conset/zhs_borrowuse/?title='.$title;
		$config['total_rows'] = $vdata['conset_count'];
		$config['per_page'] = sys_admin_LIST_PAGE_SIZE; 
		$this->pagination->initialize($config); 
				
		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'zhs_borrowuse';
		$this->load->view('/sys_admin/borrow/conset_borrowuse', $vdata);
	}
	
	function add_use_view(){
		
		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'zhs_borrowuse';
		$this->load->view('/sys_admin/borrow/conset_use_add', $vdata);
	}
	
	
	private function post_use_data(){		
		$data = array(
				'title'=>$this->input->post('title'),
				'forder'=>$this->input->post('forder'),
				'content'=>trim($this->input->post('content')),
			);
		  		
		if($data['title'] == ''){
			$ret['msg'] = '名称不能为空';
		}elseif($data['content'] == ''){
			$ret['msg'] = '借款用途不能为空';	
		}
		
		if($ret['msg']){
			echo json_encode($ret);exit;
		}
  		
  		return $data;
	}
	
	
	function add_use(){
		$data = $this->post_use_data();
  		$data['add_time'] = time();
		
  		$this->load->model('Conset_model');
  		$id = $this->Conset_model->conset_use_add($data);
  		
		$this->load->model('log_model');
		$this->log_model->add_log('[添加][借款用途设置]['.$this->input->post('title').']');
		$ret['msg'] = 1;
		echo json_encode($ret);
   		exit;
	}
	
	function edit_use_view($id){
		$this->load->model('Conset_model');
  		$conset = $this->Conset_model->get_conset_use_obj($id);
  		$vdata['conset'] = $conset;
  		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'zhs_borrowuse';
		
  		$this->load->view("/sys_admin/borrow/conset_use_edit", $vdata);
	}
	
	function edit_use(){
		$id 		= $this->input->post('id');
		
		$data = $this->post_use_data();
		
		
  		$this->load->model('Conset_model');
  		$article_id = $this->Conset_model->conset_use_update($id, $data);
  		
		$this->load->model('log_model');
		$this->log_model->add_log('[修改][借款用途设置]'.'ID=='.$id );
   		$ret['msg'] = 1;
		echo json_encode($ret);
   		exit;
	}
	
	/*
	 * 审核科目库管理
	 */
	function zhs_subject(){
		//接收参数
		$per_page 			= $this->input->get('per_page')?$this->input->get('per_page'):0;
		$title 				= $this->input->get('title');
		
		$data = array();
		if($title != ''){
			$data['where']['title'] = $title;
		}
		
		$data['page_size']  = sys_admin_LIST_PAGE_SIZE;
		$data['page_start'] = (int)$per_page;
		$data['select'] 	= 1;
		$this->load->model('Conset_model');
		$vdata = $this->Conset_model->get_conset_subject_list($data);
		
		//分页
		$this->load->library('pagination');
		$config['base_url'] = '/sys_admin/conset/zhs_subject/?title='.$title;
		$config['total_rows'] = $vdata['conset_count'];
		$config['per_page'] = sys_admin_LIST_PAGE_SIZE; 
		$this->pagination->initialize($config); 
		
		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'subject';
		$this->load->view('/sys_admin/borrow/conset_subject', $vdata);
	}
	
	
	public function doupload(){
		$ret = array(
			'msg' => '',
			'url' => ''
		);
		
		$file_format = $_POST['fformat'];
		
		$this->load->model('Conset_model');
		$conset_subject_file = $this->Conset_model->arrays('conset_subject_file');
		
		
		$thumbnail = "";
		if(isset($_FILES['thumbnail']) && $_FILES['thumbnail']['name'] != ''){
			
			$thumbnail = $this->attach(UPFILES_CONSET_SUBJECT_IMG,$_FILES['thumbnail']['tmp_name'],$_FILES['thumbnail']['name'],$file_format );
			if ($thumbnail){
				$fileinfo = '';
				$thumbnailstr = '';
				$thumbnailstr .= $thumbnail.'|'.$file_format;
				if($file_format == 1){
					$fileinfo .= '<li><a target="_blank" href="'.CONSET_SUBJECT_IMG.$thumbnail.'"><img src="'.CONSET_SUBJECT_IMG.$thumbnail.'" width="60" height="60"  /></a><br />'.$thumbnail.'<br />'.$conset_subject_file[$file_format].'<input type="hidden" name="thumbnailstr[]" value="'.$thumbnailstr.'"/></li>';
				}else{
					$fileinfo .= '<li>'.$thumbnail.'<br />'.$conset_subject_file[$file_format].'<input type="hidden" name="thumbnailstr[]" value="'.$thumbnailstr.'"/></li>';
				}				
					
				$ret['msg'] = array('thumbnail'=>$thumbnailstr,'info'=>$fileinfo);
				echo json_encode($ret);
				exit;
		
			}else{
				$ret['url'] = 'error';
				$ret['msg'] = '保存失败';
			}
		}else{
			$ret['url'] = 'error';
			$ret['msg'] = $this->upload->display_errors();
		}
		echo json_encode($ret);
		exit;
		
		
	}
	
	private function post_subject_data(){

		$thumbnailstr = $this->input->post('thumbnailstr');
		$temp = array();
		
		foreach ($thumbnailstr as $k){
			$carr = explode('|', $k);
			$ad['filename'] = $carr[0];
			$ad['fileformat'] = $carr[1];
			$temp[] = $ad;
		}
		
		
		$thumbnail = serialize($temp);
		
		$data = array(
				'thumbnail'=>$thumbnail,
				'title'=>$this->input->post('title'),
				'valid'=>$this->input->post('valid'),
				'file_format'=>$this->input->post('file_format'),
				'content'=>trim($this->input->post('content')),
			);
		  		
		if($data['title'] == ''){
			$ret['msg'] = '审核资料科目名称不能为空';
		}elseif($data['valid'] == ''){
			$ret['msg'] = '审核资料有效时间不能为空';	
		}elseif($data['content'] == ''){
			$ret['msg'] = '资料提交说明不能为空';	
		}
		
		if($ret['msg']){
			echo json_encode($ret);exit;
		}		
		  		
  		return $data;
	}
	
	function add_subject_view(){
		
		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'subject';
		
		$this->load->model('Conset_model');
		$vdata['conset_subject_valid'] = $this->Conset_model->arrays('conset_subject_valid');
  		$vdata['conset_subject_file'] = $this->Conset_model->arrays('conset_subject_file');
		
		$this->load->view('/sys_admin/borrow/conset_subject_add', $vdata);
	}
	
	// 添加审核科目
	function add_subject(){
		$data = $this->post_subject_data();
  		$data['add_time'] = time();
		
  		$this->load->model('Conset_model');
  		$id = $this->Conset_model->conset_subject_add($data);
  		
		$this->load->model('log_model');
		$this->log_model->add_log('[添加][审核科目库管理]['.$this->input->post('title').']');
		$ret['msg'] = 1;
		echo json_encode($ret);
   		exit;
	}
	
	
	function edit_subject_view($id){
		$this->load->model('Conset_model');
  		$conset = $this->Conset_model->get_conset_subject_obj($id);
  		$vdata['conset'] = $conset;
  		
  		
  		$vdata['conset_subject_valid'] = $this->Conset_model->arrays('conset_subject_valid');
  		$vdata['conset_subject_file'] = $this->Conset_model->arrays('conset_subject_file');
  		
  		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'subject';
		
  		$this->load->view("/sys_admin/borrow/conset_subject_edit", $vdata);
	}
	
	function edit_subject(){
		$id 		= $this->input->post('id');
		
		$data = $this->post_subject_data();
				
  		$this->load->model('Conset_model');
  		$article_id = $this->Conset_model->conset_subject_update($id, $data);
  		
		$this->load->model('log_model');
		$this->log_model->add_log('[修改][审核科目库管理]'.'ID=='.$id );
   		$ret['msg'] = 1;
		echo json_encode($ret);
   		exit;
	}
	
	
	/*
	 * 信用等级管理
	 */
	function zhs_credit(){
		$per_page 			= $this->input->get('per_page')?$this->input->get('per_page'):0;
		$title 				= $this->input->get('title');
		
		$data = array();
		if($title != ''){
			$data['where']['title'] = $title;
		}
		
		$data['page_size']  = sys_admin_LIST_PAGE_SIZE;
		$data['page_start'] = (int)$per_page;
		$data['select'] 	= 1;
		$this->load->model('Conset_model');
		$vdata = $this->Conset_model->get_conset_credit_list($data);
		
		//分页
		$this->load->library('pagination');
		$config['base_url'] = '/sys_admin/conset/zhs_credit/?title='.$title;
		$config['total_rows'] = $vdata['conset_count'];
		$config['per_page'] = sys_admin_LIST_PAGE_SIZE; 
		$this->pagination->initialize($config); 
		
		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'credit';
		$this->load->view('/sys_admin/borrow/conset_credit', $vdata);
	}
	
	
	private function post_credit_data(){		
		$data = array(
				'title'=>$this->input->post('title'),
				'rank'=>$this->input->post('rank'),
				'content'=>trim($this->input->post('content')),
			);
		  		
		if($data['title'] == ''){
			$ret['msg'] = '等级名称不能为空';
		}elseif($data['rank'] == ''){
			$ret['msg'] = '等级不能为空';	
		}elseif($data['content'] == ''){
			$ret['msg'] = '等级描述不能为空';	
		}
		
		if($ret['msg']){
			echo json_encode($ret);exit;
		}
		
		$thumbnail = "";
		if(isset($_FILES['thumbnail']) && $_FILES['thumbnail']['name'] != ''){
			$thumbnail = $this->upload_thumbnail(UPFILES_CONSET_IMG, CONSET_IMG,'conset_');
		}
				
  		$data['thumbnail'] 	= $thumbnail;
  		
  		return $data;
	}
	
	function add_credit_view(){
		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'credit';
		$this->load->view('/sys_admin/borrow/conset_credit_add', $vdata);
	}
	
	function add_credit(){
		$data = $this->post_credit_data();
  		$data['add_time'] = time();
		
  		$this->load->model('Conset_model');
  		$id = $this->Conset_model->conset_credit_add($data);
  		
		$this->load->model('log_model');
		$this->log_model->add_log('[添加][信用等级管理]['.$this->input->post('title').']');
		$ret['msg'] = 1;
		echo json_encode($ret);
   		exit;
	}
	
	
	function edit_credit_view($id){
		$this->load->model('Conset_model');
  		$conset = $this->Conset_model->get_conset_credit_obj($id);
  		$vdata['conset'] = $conset;
  		
  		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'credit';
		
  		$this->load->view("/sys_admin/borrow/conset_credit_edit", $vdata);
	}
	
	function edit_credit(){
		$id 		= $this->input->post('id');
		
		$data = $this->post_credit_data();
		
		$bthumbnail 		= $this->input->post('bthumbnail');
		$data['thumbnail']= $data['thumbnail']?$data['thumbnail']:$bthumbnail;
		
  		$this->load->model('Conset_model');
  		$article_id = $this->Conset_model->conset_credit_update($id, $data);
  		
		$this->load->model('log_model');
		$this->log_model->add_log('[修改][信用等级管理]'.'ID=='.$id );
   		$ret['msg'] = 1;
		echo json_encode($ret);
   		exit;
	}
	
	
	function remove_use(){
		$id 				= $this->input->post('id');
  		$data["is_del"]		= 1;
  		$this->load->model('Conset_model');
		echo  $this->Conset_model->conset_use_update($id, $data);
  		$this->load->model('log_model');$this->log_model->add_log('[删除][借款用途设置]');
	}
	
	function remove_subject(){
		$id 				= $this->input->post('id');
  		$data["is_del"]		= 1;
  		$this->load->model('Conset_model');
		echo  $this->Conset_model->conset_subject_update($id, $data);
  		$this->load->model('log_model');$this->log_model->add_log('[删除][审核科目库管理]');
	}
	
	function remove_credit(){
		$id 				= $this->input->post('id');
  		$data["is_del"]		= 1;
  		$this->load->model('Conset_model');
		echo  $this->Conset_model->conset_credit_update($id, $data);
  		$this->load->model('log_model');$this->log_model->add_log('[删除][信用等级管理]');
	}
	
	
	function view_subject(){
		$this->load->model('Conset_model');
		$id = $_POST['id'];
  		$conset = $this->Conset_model->get_conset_subject_obj($id);
  		$vdata['conset'] = $conset;
  		
  		$vdata['conset_subject_valid'] = $this->Conset_model->arrays('conset_subject_valid');
  		$vdata['conset_subject_file'] = $this->Conset_model->arrays('conset_subject_file');
  		
  		$response_html = $this->load->view('/sys_admin/borrow/show_conset_subject',$vdata,true);
		
		echo $response_html;
	}
	
	
=======
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Conset extends MY_Controller {
    	
	function __construct(){
		parent::__construct();
		/** 登陆验证 */
		if(!isset($_SESSION)){
		    session_start();
		}
		$admin = $this->session->userdata('admin_user');
		if(!$admin || !isset($admin['user_id'])){
			header('Location: /sys_admin/login');
			exit;
		}
		
		$this->tab = 'borrowtender';
	}
	
	
	/*
	 * 借款用途设置
	 */
	function zhs_borrowuse(){
		
		//接收参数
		$per_page 			= $this->input->get('per_page')?$this->input->get('per_page'):0;
		$title 				= $this->input->get('title');
		
		$data = array();
		if($title != ''){
			$data['where']['title'] = $title;
		}
		
		$data['page_size']  = sys_admin_LIST_PAGE_SIZE;
		$data['page_start'] = (int)$per_page;
		$data['select'] 	= 1;
		$this->load->model('Conset_model');
		$vdata = $this->Conset_model->get_conset_use_list($data);
		
		//分页
		$this->load->library('pagination');
		$config['base_url'] = '/sys_admin/conset/zhs_borrowuse/?title='.$title;
		$config['total_rows'] = $vdata['conset_count'];
		$config['per_page'] = sys_admin_LIST_PAGE_SIZE; 
		$this->pagination->initialize($config); 
				
		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'zhs_borrowuse';
		$this->load->view('/sys_admin/borrow/conset_borrowuse', $vdata);
	}
	
	function add_use_view(){
		
		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'zhs_borrowuse';
		$this->load->view('/sys_admin/borrow/conset_use_add', $vdata);
	}
	
	
	private function post_use_data(){		
		$data = array(
				'title'=>$this->input->post('title'),
				'forder'=>$this->input->post('forder'),
				'content'=>trim($this->input->post('content')),
			);
		  		
		if($data['title'] == ''){
			$ret['msg'] = '名称不能为空';
		}elseif($data['content'] == ''){
			$ret['msg'] = '借款用途不能为空';	
		}
		
		if($ret['msg']){
			echo json_encode($ret);exit;
		}
  		
  		return $data;
	}
	
	
	function add_use(){
		$data = $this->post_use_data();
  		$data['add_time'] = time();
		
  		$this->load->model('Conset_model');
  		$id = $this->Conset_model->conset_use_add($data);
  		
		$this->load->model('log_model');
		$this->log_model->add_log('[添加][借款用途设置]['.$this->input->post('title').']');
		$ret['msg'] = 1;
		echo json_encode($ret);
   		exit;
	}
	
	function edit_use_view($id){
		$this->load->model('Conset_model');
  		$conset = $this->Conset_model->get_conset_use_obj($id);
  		$vdata['conset'] = $conset;
  		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'zhs_borrowuse';
		
  		$this->load->view("/sys_admin/borrow/conset_use_edit", $vdata);
	}
	
	function edit_use(){
		$id 		= $this->input->post('id');
		
		$data = $this->post_use_data();
		
		
  		$this->load->model('Conset_model');
  		$article_id = $this->Conset_model->conset_use_update($id, $data);
  		
		$this->load->model('log_model');
		$this->log_model->add_log('[修改][借款用途设置]'.'ID=='.$id );
   		$ret['msg'] = 1;
		echo json_encode($ret);
   		exit;
	}
	
	/*
	 * 审核科目库管理
	 */
	function zhs_subject(){
		//接收参数
		$per_page 			= $this->input->get('per_page')?$this->input->get('per_page'):0;
		$title 				= $this->input->get('title');
		
		$data = array();
		if($title != ''){
			$data['where']['title'] = $title;
		}
		
		$data['page_size']  = sys_admin_LIST_PAGE_SIZE;
		$data['page_start'] = (int)$per_page;
		$data['select'] 	= 1;
		$this->load->model('Conset_model');
		$vdata = $this->Conset_model->get_conset_subject_list($data);
		
		//分页
		$this->load->library('pagination');
		$config['base_url'] = '/sys_admin/conset/zhs_subject/?title='.$title;
		$config['total_rows'] = $vdata['conset_count'];
		$config['per_page'] = sys_admin_LIST_PAGE_SIZE; 
		$this->pagination->initialize($config); 
		
		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'subject';
		$this->load->view('/sys_admin/borrow/conset_subject', $vdata);
	}
	
	
	public function doupload(){
		$ret = array(
			'msg' => '',
			'url' => ''
		);
		
		$file_format = $_POST['fformat'];
		
		$this->load->model('Conset_model');
		$conset_subject_file = $this->Conset_model->arrays('conset_subject_file');
		
		
		$thumbnail = "";
		if(isset($_FILES['thumbnail']) && $_FILES['thumbnail']['name'] != ''){
			
			$thumbnail = $this->attach(UPFILES_CONSET_SUBJECT_IMG,$_FILES['thumbnail']['tmp_name'],$_FILES['thumbnail']['name'],$file_format );
			if ($thumbnail){
				$fileinfo = '';
				$thumbnailstr = '';
				$thumbnailstr .= $thumbnail.'|'.$file_format;
				if($file_format == 1){
					$fileinfo .= '<li><a target="_blank" href="'.CONSET_SUBJECT_IMG.$thumbnail.'"><img src="'.CONSET_SUBJECT_IMG.$thumbnail.'" width="60" height="60"  /></a><br />'.$thumbnail.'<br />'.$conset_subject_file[$file_format].'<input type="hidden" name="thumbnailstr[]" value="'.$thumbnailstr.'"/></li>';
				}else{
					$fileinfo .= '<li>'.$thumbnail.'<br />'.$conset_subject_file[$file_format].'<input type="hidden" name="thumbnailstr[]" value="'.$thumbnailstr.'"/></li>';
				}				
					
				$ret['msg'] = array('thumbnail'=>$thumbnailstr,'info'=>$fileinfo);
				echo json_encode($ret);
				exit;
		
			}else{
				$ret['url'] = 'error';
				$ret['msg'] = '保存失败';
			}
		}else{
			$ret['url'] = 'error';
			$ret['msg'] = $this->upload->display_errors();
		}
		echo json_encode($ret);
		exit;
		
		
	}
	
	private function post_subject_data(){

		$thumbnailstr = $this->input->post('thumbnailstr');
		$temp = array();
		
		foreach ($thumbnailstr as $k){
			$carr = explode('|', $k);
			$ad['filename'] = $carr[0];
			$ad['fileformat'] = $carr[1];
			$temp[] = $ad;
		}
		
		
		$thumbnail = serialize($temp);
		
		$data = array(
				'thumbnail'=>$thumbnail,
				'title'=>$this->input->post('title'),
				'valid'=>$this->input->post('valid'),
				'file_format'=>$this->input->post('file_format'),
				'content'=>trim($this->input->post('content')),
			);
		  		
		if($data['title'] == ''){
			$ret['msg'] = '审核资料科目名称不能为空';
		}elseif($data['valid'] == ''){
			$ret['msg'] = '审核资料有效时间不能为空';	
		}elseif($data['content'] == ''){
			$ret['msg'] = '资料提交说明不能为空';	
		}
		
		if($ret['msg']){
			echo json_encode($ret);exit;
		}		
		  		
  		return $data;
	}
	
	function add_subject_view(){
		
		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'subject';
		
		$this->load->model('Conset_model');
		$vdata['conset_subject_valid'] = $this->Conset_model->arrays('conset_subject_valid');
  		$vdata['conset_subject_file'] = $this->Conset_model->arrays('conset_subject_file');
		
		$this->load->view('/sys_admin/borrow/conset_subject_add', $vdata);
	}
	
	// 添加审核科目
	function add_subject(){
		$data = $this->post_subject_data();
  		$data['add_time'] = time();
		
  		$this->load->model('Conset_model');
  		$id = $this->Conset_model->conset_subject_add($data);
  		
		$this->load->model('log_model');
		$this->log_model->add_log('[添加][审核科目库管理]['.$this->input->post('title').']');
		$ret['msg'] = 1;
		echo json_encode($ret);
   		exit;
	}
	
	
	function edit_subject_view($id){
		$this->load->model('Conset_model');
  		$conset = $this->Conset_model->get_conset_subject_obj($id);
  		$vdata['conset'] = $conset;
  		
  		
  		$vdata['conset_subject_valid'] = $this->Conset_model->arrays('conset_subject_valid');
  		$vdata['conset_subject_file'] = $this->Conset_model->arrays('conset_subject_file');
  		
  		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'subject';
		
  		$this->load->view("/sys_admin/borrow/conset_subject_edit", $vdata);
	}
	
	function edit_subject(){
		$id 		= $this->input->post('id');
		
		$data = $this->post_subject_data();
				
  		$this->load->model('Conset_model');
  		$article_id = $this->Conset_model->conset_subject_update($id, $data);
  		
		$this->load->model('log_model');
		$this->log_model->add_log('[修改][审核科目库管理]'.'ID=='.$id );
   		$ret['msg'] = 1;
		echo json_encode($ret);
   		exit;
	}
	
	
	/*
	 * 信用等级管理
	 */
	function zhs_credit(){
		$per_page 			= $this->input->get('per_page')?$this->input->get('per_page'):0;
		$title 				= $this->input->get('title');
		
		$data = array();
		if($title != ''){
			$data['where']['title'] = $title;
		}
		
		$data['page_size']  = sys_admin_LIST_PAGE_SIZE;
		$data['page_start'] = (int)$per_page;
		$data['select'] 	= 1;
		$this->load->model('Conset_model');
		$vdata = $this->Conset_model->get_conset_credit_list($data);
		
		//分页
		$this->load->library('pagination');
		$config['base_url'] = '/sys_admin/conset/zhs_credit/?title='.$title;
		$config['total_rows'] = $vdata['conset_count'];
		$config['per_page'] = sys_admin_LIST_PAGE_SIZE; 
		$this->pagination->initialize($config); 
		
		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'credit';
		$this->load->view('/sys_admin/borrow/conset_credit', $vdata);
	}
	
	
	private function post_credit_data(){		
		$data = array(
				'title'=>$this->input->post('title'),
				'rank'=>$this->input->post('rank'),
				'content'=>trim($this->input->post('content')),
			);
		  		
		if($data['title'] == ''){
			$ret['msg'] = '等级名称不能为空';
		}elseif($data['rank'] == ''){
			$ret['msg'] = '等级不能为空';	
		}elseif($data['content'] == ''){
			$ret['msg'] = '等级描述不能为空';	
		}
		
		if($ret['msg']){
			echo json_encode($ret);exit;
		}
		
		$thumbnail = "";
		if(isset($_FILES['thumbnail']) && $_FILES['thumbnail']['name'] != ''){
			$thumbnail = $this->upload_thumbnail(UPFILES_CONSET_IMG, CONSET_IMG,'conset_');
		}
				
  		$data['thumbnail'] 	= $thumbnail;
  		
  		return $data;
	}
	
	function add_credit_view(){
		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'credit';
		$this->load->view('/sys_admin/borrow/conset_credit_add', $vdata);
	}
	
	function add_credit(){
		$data = $this->post_credit_data();
  		$data['add_time'] = time();
		
  		$this->load->model('Conset_model');
  		$id = $this->Conset_model->conset_credit_add($data);
  		
		$this->load->model('log_model');
		$this->log_model->add_log('[添加][信用等级管理]['.$this->input->post('title').']');
		$ret['msg'] = 1;
		echo json_encode($ret);
   		exit;
	}
	
	
	function edit_credit_view($id){
		$this->load->model('Conset_model');
  		$conset = $this->Conset_model->get_conset_credit_obj($id);
  		$vdata['conset'] = $conset;
  		
  		$vdata['tab'] = $this->tab;
		$vdata['sub'] = 'credit';
		
  		$this->load->view("/sys_admin/borrow/conset_credit_edit", $vdata);
	}
	
	function edit_credit(){
		$id 		= $this->input->post('id');
		
		$data = $this->post_credit_data();
		
		$bthumbnail 		= $this->input->post('bthumbnail');
		$data['thumbnail']= $data['thumbnail']?$data['thumbnail']:$bthumbnail;
		
  		$this->load->model('Conset_model');
  		$article_id = $this->Conset_model->conset_credit_update($id, $data);
  		
		$this->load->model('log_model');
		$this->log_model->add_log('[修改][信用等级管理]'.'ID=='.$id );
   		$ret['msg'] = 1;
		echo json_encode($ret);
   		exit;
	}
	
	
	function remove_use(){
		$id 				= $this->input->post('id');
  		$data["is_del"]		= 1;
  		$this->load->model('Conset_model');
		echo  $this->Conset_model->conset_use_update($id, $data);
  		$this->load->model('log_model');$this->log_model->add_log('[删除][借款用途设置]');
	}
	
	function remove_subject(){
		$id 				= $this->input->post('id');
  		$data["is_del"]		= 1;
  		$this->load->model('Conset_model');
		echo  $this->Conset_model->conset_subject_update($id, $data);
  		$this->load->model('log_model');$this->log_model->add_log('[删除][审核科目库管理]');
	}
	
	function remove_credit(){
		$id 				= $this->input->post('id');
  		$data["is_del"]		= 1;
  		$this->load->model('Conset_model');
		echo  $this->Conset_model->conset_credit_update($id, $data);
  		$this->load->model('log_model');$this->log_model->add_log('[删除][信用等级管理]');
	}
	
	
	function view_subject(){
		$this->load->model('Conset_model');
		$id = $_POST['id'];
  		$conset = $this->Conset_model->get_conset_subject_obj($id);
  		$vdata['conset'] = $conset;
  		
  		$vdata['conset_subject_valid'] = $this->Conset_model->arrays('conset_subject_valid');
  		$vdata['conset_subject_file'] = $this->Conset_model->arrays('conset_subject_file');
  		
  		$response_html = $this->load->view('/sys_admin/borrow/show_conset_subject',$vdata,true);
		
		echo $response_html;
	}
	
	
>>>>>>> d47623b610d79a4eeb489500830c00d70933f414
}